package com.rs.game.player.dialogues;

import com.rs.game.WorldTile;
import com.rs.game.npc.others.Bork;
import com.rs.game.player.Skills;
import com.rs.game.player.content.GlacorDungeon;
import com.rs.game.player.content.LavaFlowMines;
import com.rs.game.player.content.Magic;
import com.rs.game.player.controlers.Falconry;
import com.rs.game.player.controlers.FightKiln;

public class Teleporter extends Dialogue {

	
	/**
	 * Represents the the loyalty manager.
	 * 
	 * @author Light <w199508@gmail.com>
	 */
	
	@Override
	public void start() {
		sendOptionsDialogue("Teleports", "Boss Teleports", "Slayer Teleports", "Monster Teleports", "Training Teleports", "Next page");
	}

	@Override
	public void run(int interfaceId, int componentId) {
	if (stage == -1) {
		if (componentId == OPTION_1) {
		sendOptionsDialogue("Boss Teleports", "Kalphite Queen", "Corporeal Beast", "King Black Dragon (Wilderness!)", "Queen Black Dragon", "More");
		stage = 0;
		}
		if (componentId == OPTION_2) {
		sendOptionsDialogue("Slayer Teleports", "Ancient Cavern", "Slayer Tower", "PolyPore Dungeon", "Taverly Dungeon", "Back");
		stage = 1;
		}
		if (componentId == OPTION_3) {
		sendOptionsDialogue("Monster Teleports", "Glacors", "Ice Strykwyrms", "Desert Strykwyrms", "Jungle Styrkewyrms", "Frost Dragons");
		stage = 2;
		}
		if (componentId == OPTION_4) {
		sendOptionsDialogue("Training Teleports", "Rats", "Cows", "Rock Crabs", "Hill Giants", "Back");	
		stage = 3;
		}
		if (componentId == OPTION_5) {
		sendOptionsDialogue("Teleports", "Dungeon Teleports", "MiniGame Teleports", "Skilling Teleports", "Back");
		stage = 4;			
		}
	} else if (stage == 0) {
		if (componentId == OPTION_1) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3507, 9493, 0));
		end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2966, 4383, 2));	
		end ();
		}
		if (componentId == OPTION_3) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3069, 10255, 0));
		player.getControlerManager().startControler("Wilderness");
		end ();
		}
		if (componentId == OPTION_4) {
			if (player.getSkills().getLevelForXp(Skills.SUMMONING) < 60) {
				player.getPackets().sendGameMessage("You need a summoning level of 60 to go through this portal.");
				return;
			}
			player.getControlerManager().startControler("QueenBlackDragonControler");
			end();	
		}
		if (componentId == OPTION_5) {
		sendOptionsDialogue("Boss Teleports", "Bork", "Dagannoth Kings", "GodWars", "Tormented Demons", "Back");
		stage = 5;
		}
	} else if (stage == 1) {
		if (componentId == OPTION_1) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(1738, 5312, 1));
		end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3429, 3534, 0));	
		end ();
		}
		if (componentId == OPTION_3) {
			if (player.getSkills().getLevelForXp(Skills.MAGIC) < 60) {
				player.getPackets().sendGameMessage("You need at least a magic level of 60 to enter this dungeon.",false);
				return;
			} else 
				Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(4621, 5458, 3));
			end ();
		}
		if (componentId == OPTION_4) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2883, 9800, 0));
		end ();
		}
		if (componentId == OPTION_5) {
		player.getDialogueManager().startDialogue("Teleporter");
		}
	} else if (stage == 2) {
		if (componentId == OPTION_1) {
		player.setNextWorldTile(new WorldTile(4180, 5720, 0));
		GlacorDungeon.EnterDungeonBoost(player);	
		end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3422, 5668, 0));	
		end ();
		}
		if (componentId == OPTION_3) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3336, 3163, 0));		
		end ();
		}
		if (componentId == OPTION_4) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2444, 2888, 0));
		end ();
		}
		if (componentId == OPTION_5) {
			if (player.getSkills().getLevelForXp(Skills.DUNGEONEERING) >= 85) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(1298, 4509, 0));
			end ();
			} else 
				end();
				player.getPackets().sendGameMessage("You must have level 85 dungeoneering to access these.");
			
		}
	} else if (stage == 3) {
		if (componentId == OPTION_1) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3104, 9513, 0));
		end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3176, 3317, 0));	
		end ();
		}
		if (componentId == OPTION_3) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2710, 3710, 0));	
		end ();
		}
		if (componentId == OPTION_4) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3117, 9853, 0));	
		end ();
		}
		if (componentId == OPTION_5) {
		player.getDialogueManager().startDialogue("Teleporter");	
		}
	} else if (stage == 4) {
		if (componentId == OPTION_1) {
		sendOptionsDialogue("Dungeon Teleports", "Fremennik Dungeon", "Revenant Cave", "Tolna's Rift (Dragons)", "Grotworms Liar", "Back" );
		stage = 6;
		}
		if (componentId == OPTION_2) {
		sendOptionsDialogue("MiniGame Teleports", "Fight Pits", "Fight Caves", "Fight Kiln", "ClanWars", "More" );	
		stage = 7;
		}
		if (componentId == OPTION_3) {
		sendOptionsDialogue("Skilling Teleports", "Achievement Capes", "Fishing", "Summoning", "Woodcutting", "More");
		stage = 10;
		}
		if (componentId == OPTION_4) {
		player.getDialogueManager().startDialogue("Teleporter");
		}
	} else if (stage == 5) {
		if (componentId == OPTION_1) {
			if (Bork.deadTime > System.currentTimeMillis()) {
				player.getPackets().sendGameMessage(Bork.convertToTime());
				return;
			}
			player.getControlerManager().startControler("BorkControler", 0, null);
			end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(1909, 4367, 0));	
		end ();
		}
		if (componentId == OPTION_3) {
		sendOptionsDialogue("Godwars", "Nex", "Bandos", "Armadyl", "Saradomin", "Zamorak");	
		stage = 8;
		}
		if (componentId == OPTION_4) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2571, 5734, 0));	
		end ();
		}
		if (componentId == OPTION_5) {
		sendOptionsDialogue("Boss Teleports", "Kalphite Queen", "Corporeal Beast", "King Black Dragon (Wilderness!)", "Queen Black Dragon", "More");
		stage = 0;	
		}
	} else if (stage == 6) {
		if (componentId == OPTION_1) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2808, 10002, 0));
		end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3071, 3649, 0));	
		end ();
		}
		if (componentId == OPTION_3) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3297, 9824, 0));	
		end ();
		}
		if (componentId == OPTION_4) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(1205, 6372, 0));	
		end ();
		}
		if (componentId == OPTION_5) {
		sendOptionsDialogue("Teleports", "Dungeon Teleports", "MiniGame Teleports", "Back");
		stage = 4;		
		}
	} else if (stage == 7) {
		if (componentId == OPTION_1) {// Fight Pits
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(4601, 5061, 0));
		end ();
		}
		if (componentId == OPTION_2) {// Fight Caves
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(4611, 5129, 0));
		end ();
		}
		if (componentId == OPTION_3) {// Fight Kiln
		Magic.sendNormalTeleportSpell(player, 0, 0, FightKiln.OUTSIDE);
		end ();
		}
		if (componentId == OPTION_4) {// Clan wars
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2995, 9679, 0));
		end ();
		}
		if (componentId == OPTION_5) {
		sendOptionsDialogue("MiniGame Teleports", "Barrows", "Dominion Tower", "Castle Wars", "Warriors Guild", "Duel Arena");	
		stage = 9;
		}
	} else if (stage == 8) {
		if (componentId == OPTION_1) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2904, 5203, 0));
		end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2870, 5363, 0));	
		end ();
		}
		if (componentId == OPTION_3) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2838, 5297, 0));	
		end ();
		}
		if (componentId == OPTION_4) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2923, 5247, 0));	
		end ();
		}
		if (componentId == OPTION_5) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2925, 5330, 0));
		end ();
		}
	} else if (stage == 9) {
		if (componentId == OPTION_1) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3565, 3289, 0));
		end ();
		}
		if (componentId == OPTION_2) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3366, 3083, 0));	
		end ();
		}
		if (componentId == OPTION_3) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2442, 3090, 0));
		end ();
		}
		if (componentId == OPTION_4) {
		Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2878, 3542, 0));		
		end ();
		}
		if (componentId == OPTION_5) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3365,
					3275, 0));
			player.getControlerManager().startControler("DuelControler");
		}
	} else if (stage == 10) {
		if (componentId == OPTION_1) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3499, 3620, 0));

		} 
		if (componentId == OPTION_2) {
			sendOptionsDialogue("Fishing", "Living Rock Caverns", "Fishing Guild");
			stage = 11;

		} 
		if (componentId == OPTION_3) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2926, 3448, 0));

		} 
		if (componentId == OPTION_4) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2726, 3484, 0));

		} 
		if (componentId == OPTION_5) {
			sendOptionsDialogue("Skilling Teleports", "Mining", "Agility", "Hunter", "Runecrafting", "More");
			stage = 12;
		}
	} else if (stage == 11) {
		if (componentId == OPTION_1) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3651, 5122, 0));
		} 
		if (componentId == OPTION_2) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2591, 3420, 0));
		} 
	} else if (stage == 12) {
		if (componentId == OPTION_1) {
			sendOptionsDialogue("Mining Teleports", "Mining", "LavaFlow Mines", "Back");
			stage = 16;
		} 
		if (componentId == OPTION_2) {
			sendOptionsDialogue("Agility", "Gnome Agility Course", "Barbarian Outpost Course", "Wilderness Course (!Dangerous!)");
			stage = 13;
		} 
		if (componentId == OPTION_3) {
			sendOptionsDialogue("Hunter Teleports", "Hunter", "Falconry");
			stage = 14;
		} 
		if (componentId == OPTION_4) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2599, 3159, 0));
		} 
		if (componentId == OPTION_5) {
			sendOptionsDialogue("Skilling Locations", "Dungeoneering", "Farming");
			stage = 15;
		}
	} else if (stage == 13) {
		if (componentId == OPTION_1) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2472, 3438, 0));
		} 
		if (componentId == OPTION_2) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2552, 3556, 0));
		}
		if (componentId == OPTION_3) {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2998, 3915, 0));
			player.getControlerManager().startControler("Wilderness");
		}
	} else if (stage == 14) {
		if (componentId == OPTION_1) { 
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(2525, 2916, 0));
			end ();
		} 
		if (componentId == OPTION_2) {
			if (player.getEquipment().hasShield() || player.getEquipment().hasTwoHandedWeapon() || player.getEquipment().getWeaponId() != -1) {
				player.getPackets().sendGameMessage("Please free your hands before going here.");
				end();
			} else {
				Falconry.beginFalconry(player);
				end ();
			}
		}
	} else if (stage == 15) {
		if (componentId == OPTION_1) { 
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3449, 3698, 0));
		} 
		if (componentId == OPTION_2) { 
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3056, 3309, 0));
		}
	} else if (stage == 16) {
		if (componentId == OPTION_1) { 
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3298, 3285, 0));
		} 
		if (componentId == OPTION_2) { 
			LavaFlowMines.Entering(player);
		}
		if (componentId == OPTION_3) {
			sendOptionsDialogue("Skilling Teleports", "Mining", "Agility", "Hunter", "Runecrafting", "More");
			stage = 12;
		}
	}
}

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		
	}

}
